<form action="" method="post">
<fieldset><legend>Editace řádku</legend>
<? foreach ($forms as $form) if ($form["editkey"]) { ?>
<input type="hidden" name="editkey[<?=$form["field"]?>]" value="<?=$form["value"]?>" />
<? } ?>
<input type="hidden" name="save" value="1" />
<input type="hidden" name="table" value="<?=$_GET["table"]?>" />
<? if ($_GET["col"] == "dbmister_where") { ?>
<input type="hidden" name="editkey[<?=$_GET["col"]?>]" value="<?=$_GET["val"]?>" />
<? } ?>
<table class="forms">
<? foreach ($forms as $form) if (is_null($form["editkey"]) AND ($form["visible"] OR empty($_GET["val"]) )) { ?>
<tr>
<th style="width: 80px"><label for="col_<?=$form["field"]?>"><? if (!empty($form["set_title"])) echo $form["set_title"]; else echo $form["field"]; ?>:&nbsp;</label></th>
<td style="width: 450px">
<? if ($form["forkey"]) { ?>
<?

    $for_buff = $GLOBALS["db"]->loadList($form["forkey"]["remote_table"]);
    $for_key = $form["forkey"]["remote_field"];
    
    foreach ($for_buff as $fbv)
    {
        foreach ($fbv as $lk => $lv) $pat["[".$lk."]"] = $lv;
        $list[$fbv[$for_key]] = strtr($form["forkey_string"], $pat);
        unset($pat);
    }
    unset($fbv);
    
    unset($for_buff);

?>
<select name="cols[<?=$form["field"]?>]">
<? unset($lk); unset($lv);
   foreach ($list as $lk => $lv) { ?>
    <option value="<?=$lk?>"<? if ($lk == $form["value"]) echo " selected"; ?> /><? if (!empty($lv)) echo $lv; else echo $lk; ?></option>
<? } ?>
</select>
<? unset($list); } elseif ($form["input_type"] == "text") { ?>
<input type="<?=$form["input_type"]?>" name="cols[<?=$form["field"]?>]" id="col_<?=$form["field"]?>" value="<?=$form["value"]?>" maxlength="<?=$form["size"]?>" style="width: 100%" />
<? } else if ($form["input_type"] == "radio") { ?>
    <? foreach ($form["options"] as $opt) { ?>
    <input type="<?=$form["input_type"]?>" name="cols[<?=$form["field"]?>]" id="col_<?=$form["field"]?>_<?=$opt?>" value="<?=$opt?>" <? if ($form["value"] == $opt) echo "checked" ?> />
    <label for="col_<?=$form["field"]?>_<?=$opt?>"><? if (!empty($form["options_set"])) echo $form["options_set"][$opt]; else echo $opt; ?></label><br />
    <? } ?>
<? } else if ($form["input_type"] == "textarea") { ?>
<textarea name="cols[<?=$form["field"]?>]" style="width: 100%; height: 100px;"><?=$form["value"]?></textarea>
<? } ?>
</td>
</tr>
<? } ?>
</table>
</fieldset>

<div id="footerbox">
    <button type="submit">Uložit</button>
    <button onclick="if (confirm('Opravdu zrušit editaci?')) parent.parent.GB_CURRENT.hide(); return false;">Stornovat</button>
    <? if(!empty($_GET["val"])) { ?>
    <button onclick="if (confirm('Opravdu chcete odstranit tento záznam?')) window.location.href='DeleteRow.php?table=<?=urlencode($_GET["table"])?>&amp;col=<?=urlencode($_GET["col"])?>&amp;val=<?=urlencode($_GET["val"])?>'; return false;">Odstranit</button>
    <? } ?>
</div>
</form>
